package com.uc_ui;


import de.greenrobot.event.EventBus;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

class MPagerFrament extends Fragment{
		private String[] title = {"item" , "item" ,"item" , "item" ,"item" , "item" ,"item" , "item" ,"item" , "item" ,
				"item" , "item" ,"item" , "item" ,"item" , "item" ,"item" , "item" ,"item" , "item" ,
				"item" , "item" ,"item" , "item" ,"item" , "item" ,"item" , "item" ,};
		private ListView lv;
		private View v;
		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			v = inflater.inflate(R.layout.fragment, container , false);
			lv = (ListView) v.findViewById(R.id.lv);
			lv.setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1 , android.R.id.text1 , title));
			lv.setOnScrollListener(new OnScrollListener() {
				
				@Override
				public void onScrollStateChanged(AbsListView view, int scrollState) {
					
				}
				
				@Override
				public void onScroll(AbsListView view, int firstVisibleItem,
						int visibleItemCount, int totalItemCount) {
					 if (lv != null && lv.getChildCount() > 0 && lv.getFirstVisiblePosition() == 0) {
				          if (lv.getChildAt(0).getTop() >= 0) {
				              EventBus.getDefault().post(true);
				          }
				     }else{
				    	 EventBus.getDefault().post(false);
				     }
				}
			});
			return v;
		}
	}